package com.book.service.impl;

import com.book.entity.Account;
import com.book.mapper.AccountMapper;
import com.book.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author SuperYu
 * @date 2024/4/19
 */
@Service
public class AccountServiceImpl implements AccountService {

    private AccountMapper mapper;

    @Autowired
    public void setMapper(AccountMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public List<Account> findAllAccounts() {
        return mapper.selectAll();
    }

    @Override
    public Account findAccountByLogin(String userName) {
        Example example = new Example(Account.class);
        Example.Criteria c = example.createCriteria();
        c.andEqualTo("userName",userName);
        return mapper.selectOneByExample(example);
    }
}
